/// 导入UserData模型
import 'user_check_response.dart';

/// 用户信息更新响应模型
class UserUpdateResponse {
  final String status;
  final String message;
  final int affectedRows;
  final UserData? data;

  UserUpdateResponse({
    required this.status,
    required this.message,
    required this.affectedRows,
    this.data,
  });

  /// 从JSON创建实例
  factory UserUpdateResponse.fromJson(Map<String, dynamic> json) {
    return UserUpdateResponse(
      status: json['status'] ?? '',
      message: json['message'] ?? '',
      affectedRows: json['affected_rows'] ?? 0,
      data: json['data'] != null ? UserData.fromJson(json['data']) : null,
    );
  }

  /// 转换为JSON
  Map<String, dynamic> toJson() {
    return {
      'status': status,
      'message': message,
      'affected_rows': affectedRows,
      if (data != null) 'data': data!.toJson(),
    };
  }

  /// 判断是否成功
  bool get isSuccess => status == 'success';

  @override
  String toString() {
    return 'UserUpdateResponse{status: $status, message: $message, affectedRows: $affectedRows, data: $data}';
  }
}
